package game.efekti;

import util.INIGroup;
import game.Character;
import game.EffectStage;
import game.MagicEffect;
import game.Item.ItemType;

public class IncHealth extends MagicEffect {
	int h = 0;
	
	@Override
	public boolean canHazTip(ItemType tip) {
		return tip == ItemType.POTION;
	}

	@Override
	public void doEffect(Character c1, Character c2) {
		c1.setHealth(c1.getHealth() + h);
	}

	@Override
	public void generateForLevel(int lvl) {
		if(lvl < 5) { h = 20; return; }
		if(lvl < 10) { h = 50; return; }
		if(lvl < 20) { h = 100; return; }
		if(lvl < 50) { h = 200; return; }
		h = 500;
	}

	public String toString()
	{
		return "Heals " + h + " HP";
	}

	@Override
	public EffectStage getStage() {
		return EffectStage.CasterOnUse;
	}

	@Override
	public boolean loadFromFile(INIGroup grupa) {
		tag = grupa.getString("Tag");
		h = grupa.getInteger("HP", 0);
		return true;
	}

	@Override
	public void init() {}

	@Override
	public boolean stacksWith(MagicEffect e) {
		return e instanceof IncHealth;
	}

	@Override
	public void absorb(MagicEffect e) {
		if(stacksWith(e))
			h += ((IncHealth)e).h;
	}
}
